<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">导入文件:</label>
        <div class="col-xs-12 col-sm-8">
            <div class="input-group">
                <input id="c-file" class="form-control" size="50" name="row[file]" type="text">
                <div class="input-group-addon no-border no-padding">
                    <span><button type="button" id="faupload-file" class="btn btn-danger faupload" data-input-id="c-file" data-multiple="false" data-preview-id="p-file" data-url="{:url('ajax/localupload')}"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
                    <span><button type="button" id="fachoose-file" class="btn btn-primary fachoose" data-input-id="c-file" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
                </div>
                <span class="msg-box n-right" for="c-file"></span>
            </div>
            <ul class="row list-inline faupload-preview" id="p-file"></ul>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">分发渠道:</label>
        <div class="col-xs-12 col-sm-8">
            
            <div class="radio">
            {foreach name="channel" item="vo"}
            <label for="row[channel]-{$key}"><input id="row[channel]-{$key}" name="row[channel]" type="radio" value="{$vo.id}" /> {$vo.name}</label> 
            {/foreach}
            </div>

        </div>
    </div>
    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" id="submit1" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
        </div>
    </div>
</form>
<script src="__CDN__/assets/libs/jquery/dist/jquery.min.js"></script>
<script>
    window.onload = function(){
        var submit1 = document.getElementById("submit1");
        var form = document.getElementById("add-form");
        let isClicked = false;
        if (submit1!=undefined) {
            submit1.onclick = function(e){
                parent.layer.closeAll();
                e.preventDefault();
                var file = $('#c-file').val();
                var channel = $('input:radio:checked').val();
                if (!file || !channel) {
                    alert('参数不正确')
                    return false
                }
                var url = "<?php echo $importorderurl ?>"
                url = url+'&file='+file+'&channel='+channel;
                window.open(url);
            }
        }
    }
</script>
